<?php
/*
 * Thong tin nghe nghiep
 */
?>
<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
    'id' => 'thongtinnghenghiep-form',
    'type' => 'horizontal',
    'action' => Yii::app()->getBaseUrl(true).'/ungvien/tintimviec.html'. $hid > 0 ? '?id='.$hid : '',
    'method' => 'post',
    'enableClientValidation' => true,
    //'enableAjaxValidation' => true,
    'clientOptions' => array(
        'validateOnSubmit' => true,
    ),
        ));
?>
<!-- message -->
<?php
$this->widget('bootstrap.widgets.TbAlert', array(
        'block' => true, // display a larger alert block?
        'fade' => true, // use transitions?
        'closeText' => '&times;',
        'htmlOptions' => array(
            'style' => 'margin-bottom:2px;'
        ),
        'alerts' => array(// configurations per alert type
            'success' => array('block' => true, 'fade' => true, 'closeText' => '&times;'), // success, info, warning, error or danger
        )
    ));

$this->widget('bootstrap.widgets.TbAlert', array(
        'block' => true, // display a larger alert block?
        'fade' => true, // use transitions?
        'closeText' => '&times;',
        'htmlOptions' => array(
            'style' => 'margin-bottom:2px;'
        ),
        'alerts' => array(// configurations per alert type
            'error' => array('block' => true, 'fade' => true, 'closeText' => '&times;'), // success, info, warning, error or danger
        )
    ));
?>



<?php echo $form->textFieldRow($model, 'vitriungtuyen', array('class' => 'span7', 'hint' => 'Để nhà tuyển dụng tìm thấy hồ sơ của bạn chính xác và nhanh chóng, hãy điền vị trí mong muốn như gợi ý: VD: Biên tập viên, Giám đốc Dự án, Nhân viên Marketing...')); ?>

<legend id="step1" class='title-field title-jobs'><i class='icon icon-plus-sign mt_5 icon-white'></i> Thông tin nghề nghiệp</legend>

<?php echo $form->dropDownListRow($model, 'nganhnghe', CHtml::listData(Nganhnghe::model()->findAllByAttributes(array('published' => 1)), 'id', 'name'), array('prompt' => 'Được phép tối đa 3 ngành', 'class' => 'span4')); ?>

<div class='control-group showsub'>
    <ul id='sub-nganhgnhe'>
        <?php
        if (count($hoso_nganhnghe) > 0) {
            foreach ($hoso_nganhnghe as $item) {
                if ($item->nganhnghe->name == '')
                    continue;
                ?>
                <li style="display: list-item;">
                    <?php echo $item->nganhnghe->name; ?>
                    <span class="del-sub-nn">Xóa</span>
                    <input type="hidden" value="<?php echo $item->nganhnghe->id; ?>" name="ThongTinNgheNghiepForm[nganhnghe][]">
                </li>
                <?php
            }
        }
        ?>
    </ul>
</div>
<?php echo $form->dropDownListRow($model, 'capbac', CHtml::listData(Capbac::model()->findAllByAttributes(array('published' => 1)), 'id', 'name'), array('prompt' => '- Chọn -', 'style' => 'clear:both;', 'class' => 'span4')); ?>
<?php echo $form->dropDownListRow($model, 'bangcap', CHtml::listData(Bangcap::model()->findAllByAttributes(array('published' => 1)), 'id', 'name'), array('prompt' => '- Chọn -', 'class' => 'span4')); ?>
<?php echo $form->dropDownListRow($model, 'kinhnghiem', CHtml::listData(Kinhnghiem::model()->findAllByAttributes(array('published' => 1)), 'id', 'name'), array('prompt' => '- Chọn -', 'style' => 'clear:both;', 'class' => 'span4')); ?>

<div class='div-row'>
    <label class='mt w150'>Ngoại ngữ:</label>
    <p class='nn-row' stt='1'>                                
        <?php echo CHtml::dropDownList('ThongTinNgheNghiepForm[trinh_do_nn][ngoaingu][]', '', CHtml::listData(Ngoaingu::model()->findAllByAttributes(array('published' => 1)), 'id', 'name'), array('class' => 'span4', 'prompt' => '- Chọn -')); ?>
        Trình độ: 
        <?php echo CHtml::dropDownList('ThongTinNgheNghiepForm[trinh_do_nn][level][]', '', CHtml::listData(Trinhdo::model()->findAllByAttributes(array('published' => 1)), 'id', 'name'), array('class' => 'span2', 'prompt' => '- Chọn -')); ?>
    </p> 
    <div class='btn-add-nn'><i class='icon-plus-sign' ></i><a href="#" class='add-nn'>Thêm</a></span></div>
    <div class="sub-nn">
        <?php
        if (count($hoso_trinhdongoaingu) > 0) {
            $stt = 11;
            foreach ($hoso_trinhdongoaingu as $key => $value) {
                if($value->ngoaingu->id == '')
                    continue;
                ?>
                <p class='nn-row stt-<?php echo $stt; ?>' stt='<?php echo $stt; ?>'>
                    <?php echo CHtml::dropDownList('ThongTinNgheNghiepForm[trinh_do_nn][ngoaingu][]', $value->ngoaingu->id, CHtml::listData(Ngoaingu::model()->findAllByAttributes(array('published' => 1)), 'id', 'name'), array('class' => 'span4', 'prompt' => '- Chọn -')); ?>
                    Trình độ: 
                    <?php echo CHtml::dropDownList('ThongTinNgheNghiepForm[trinh_do_nn][level][]', $value->trinhdo->id, CHtml::listData(Trinhdo::model()->findAllByAttributes(array('published' => 1)), 'id', 'name'), array('class' => 'span2', 'prompt' => '- Chọn -')); ?>
                <div class='btn-add-nn stt-<?php echo $stt; ?>' stt='<?php echo $stt; ?>'><i class='icon-minus-sign'></i><a href="#" class='del-nn'>Xóa</a></span></div>
                </p>
                <?php
                ++$stt;
            }//end foreach
        } else {
        ?>
            <p class='nn-row' stt='1'>                                
                <?php echo CHtml::dropDownList('ThongTinNgheNghiepForm[trinh_do_nn][ngoaingu][]', '', CHtml::listData(Ngoaingu::model()->findAllByAttributes(array('published' => 1)), 'id', 'name'), array('class' => 'span4', 'prompt' => '- Chọn -')); ?>
                Trình độ: 
                <?php echo CHtml::dropDownList('ThongTinNgheNghiepForm[trinh_do_nn][level][]', '', CHtml::listData(Trinhdo::model()->findAllByAttributes(array('published' => 1)), 'id', 'name'), array('class' => 'span2', 'prompt' => '- Chọn -')); ?>
            </p> 
            <div class='btn-add-nn'><i class='icon-plus-sign'></i><a href="#" class='add-nn'>Thêm</a></span></div>
        <?php }//end else ?>
    </div>                           
</div>

<div id='nn'>
    <div class='div-row'>
        <label class='mt w150'>Lương đề nghị:</label>
        <p class='nn-row' stt='1'>
            <?php echo CHtml::dropDownList('ThongTinNgheNghiepForm[luongdenghi][luong]',$model->luongdenghi , CHtml::listData(Luong::model()->findAllByAttributes(array('published' => 1)), 'id', 'name'), array('class' => 'span3', 'prompt' => '- Chọn -')); ?>
            Từ:  <input <?php if($hoso_luong->tu > 0 ){ ?> value='<?php echo $hoso_luong->tu; ?>' <?php }else{ ?> disabled='disabled' <?php } ?> type="text" name='ThongTinNgheNghiepForm[luongdenghi][tu]' class='span2 ar sa' onkeyup="BlockChar(this,'NotNumbers')">
            Đến: <input <?php if($hoso_luong->den > 0 ){ ?> value='<?php echo $hoso_luong->den; ?>' <?php }else{ ?> disabled='disabled' <?php } ?> type='text' name='ThongTinNgheNghiepForm[luongdenghi][den]' class='span2 ar sa' onkeyup="BlockChar(this,'NotNumbers')">
        </p> 
    </div>
</div>
<?php echo $form->textAreaRow($model, 'muctieunghenghiep', array('class' => 'span7')); ?>
<div class='control-group showsub count'>
    (Mục tiêu nghề nghiệp không được quá <input id='kt' value='4000' class='span1' /> kí tự)
</div>
<?php echo $form->dropDownListRow($model, 'hinhthuc', CHtml::listData(Hinhthuc::model()->findAllByAttributes(array('published' => 1)), 'id', 'name'), array('prompt' => '- Chọn -', 'class' => 'span4')); ?>
<div class='control-group showsub'>
    <ul id='sub-hinhthuc'>
        <?php
        if (count($hoso_hinhthuc) > 0) {
            foreach ($hoso_hinhthuc as $item) {
                if ($item->hinhthuc->name == '')
                    continue;
                ?>
                <li style="display: list-item;">
                    <?php echo $item->hinhthuc->name; ?>
                    <span class="del-sub-ht">Xóa</span>
                    <input type="hidden" value="<?php echo $item->hinhthuc->id; ?>" name="ThongTinNgheNghiepForm[hinhthuc][]">
                </li>
                <?php
            }
        }
        ?>
    </ul>
</div>
<?php echo $form->dropDownListRow($model, 'loaihinh', CHtml::listData(Loaihinh::model()->findAllByAttributes(array('published' => 1)), 'id', 'name'), array('prompt' => '- Chọn -', 'class' => 'span4')); ?>
<div class='control-group showsub'>
    <ul id='sub-loaihinh'>
         <?php
        if (count($hoso_loaihinh) > 0) {
            foreach ($hoso_loaihinh as $item) {
                if ($item->loaihinh->name == '')
                    continue;
                ?>
                <li style="display: list-item;">
                    <?php echo $item->loaihinh->name; ?>
                    <span class="del-sub-lh">Xóa</span>
                    <input type="hidden" value="<?php echo $item->loaihinh->id; ?>" name="ThongTinNgheNghiepForm[loaihinh][]">
                </li>
                <?php
            }
        }
        ?>
    </ul>
</div>
<div class='div-row'>
    <label class='mt w150'>Nơi làm việc mong muốn:</label>
    <p class='nn-row' stt='1'>
        <span>Trong nước:</span>
        <?php echo CHtml::dropDownList('ThongTinNgheNghiepForm[noilamviecmongmuon][tinhthanh][]', '', CHtml::listData(Thanhpho::model()->findAllByAttributes(array('quocgia_id' => 1)), 'id', 'name'), array('class' => 'span4', 'prompt' => 'Được chọn tối đa 3 địa điểm')); ?>
    <div class='showsub clearfix mt_10'>
        <ul id='sub-tinhthanh'>
            <?php
        if (count($hoso_thanhpho) > 0) {
            foreach ($hoso_thanhpho as $item) {
                if ($item->thanhpho->name == '')
                    continue;
                ?>
                <li style="display: list-item;">
                    <?php echo $item->thanhpho->name; ?>
                    <span class="del-sub-tt">Xóa</span>
                    <input type="hidden" value="<?php echo $item->thanhpho->id; ?>" name="ThongTinNgheNghiepForm[noilamviecmongmuon][tinhthanh][]">
                </li>
                <?php
            }
        }
        ?>
        </ul>
    </div>
</p> 
</div>

<div class='div-row'>
    <label class='mt w150'>&nbsp;</label>
    <p class='nn-row' stt='1'>
        <span>Nước ngoài:</span>
        <?php echo CHtml::dropDownList('ThongTinNgheNghiepForm[noilamviecmongmuon][quocgia][]', $hoso_quocgia , CHtml::listData(Quocgia::model()->findAll('id!=:quocgia_id', array(':quocgia_id' => 1)), 'id', 'name'), array('class' => 'span4', 'prompt' => 'Được phép tối đa 3 quốc gia')); ?>
    </p> 
    <div class='clearfix mt_10 showsub'>
        <ul id='sub-quocgia'>
            <?php
        if (count($hoso_quocgia) > 0) {
            foreach ($hoso_quocgia as $item) {
                if ($item->quocgia->name == '')
                    continue;
                ?>
                <li style="display: list-item;">
                    <?php echo $item->quocgia->name; ?>
                    <span class="del-sub-qg">Xóa</span>
                    <input type="hidden" value="<?php echo $item->quocgia->id; ?>" name="ThongTinNgheNghiepForm[noilamviecmongmuon][quocgia][]">
                </li>
                <?php
            }
        }
        ?>
        </ul>
    </div>  
</div>
<div class='div-row'>
    <label class='mt w150'>&nbsp;</label>
    <p class='nn-row'>
        <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => 'Cập nhật', 'icon' => 'icon-refresh icon-white')); ?>
    </p> 
</div>
<?php $this->endWidget(); ?> 
<script>
    $(document).ready(function(){
        //check edit
<?php
if (count($hoso_nganhnghe) > 0) {
    foreach ($hoso_nganhnghe as $item) {
        if ($item->nganhnghe->name == '')
            continue;
        ?>
            $('#ThongTinNgheNghiepForm_nganhnghe option[value="<?php echo $item->nganhnghe->id; ?>"]').attr('disabled','disabled');
            $('#ThongTinNgheNghiepForm_nganhnghe option[value="<?php echo $item->nganhnghe->id; ?>"]').attr('selected','selected');
            $('#ThongTinNgheNghiepForm_nganhnghe option[value="<?php echo $item->nganhnghe->id; ?>"]').addClass('sel');
        <?php
    }
}
if (count($hoso_hinhthuc) > 0) {
    foreach ($hoso_hinhthuc as $item) {
        if ($item->hinhthuc->name == '')
            continue;
        ?>
            $('#ThongTinNgheNghiepForm_hinhthuc option[value="<?php echo $item->hinhthuc->id; ?>"]').attr('disabled','disabled');
            $('#ThongTinNgheNghiepForm_hinhthuc option[value="<?php echo $item->hinhthuc->id; ?>"]').attr('selected','selected');
            $('#ThongTinNgheNghiepForm_hinhthuc option[value="<?php echo $item->hinhthuc->id; ?>"]').addClass('sel');
        <?php
    }
}
if (count($hoso_loaihinh) > 0) {
    foreach ($hoso_loaihinh as $item) {
        if ($item->loaihinh->name == '')
            continue;
        ?>
            $('#ThongTinNgheNghiepForm_loaihinh option[value="<?php echo $item->loaihinh->id; ?>"]').attr('disabled','disabled');
            $('#ThongTinNgheNghiepForm_loaihinh option[value="<?php echo $item->loaihinh->id; ?>"]').attr('selected','selected');
            $('#ThongTinNgheNghiepForm_loaihinh option[value="<?php echo $item->loaihinh->id; ?>"]').addClass('sel');
        <?php
    }
}
if (count($hoso_quocgia) > 0) {
    foreach ($hoso_quocgia as $item) {
        if ($item->quocgia->name == '')
            continue;
        ?>
            $('#ThongTinNgheNghiepForm_noilamviecmongmuon_quocgia option[value="<?php echo $item->quocgia->id; ?>"]').attr('disabled','disabled');
            $('#ThongTinNgheNghiepForm_noilamviecmongmuon_quocgia option[value="<?php echo $item->quocgia->id; ?>"]').attr('selected','selected');
            $('#ThongTinNgheNghiepForm_noilamviecmongmuon_quocgia option[value="<?php echo $item->quocgia->id; ?>"]').addClass('sel');
        <?php
    }
}
if (count($hoso_thanhpho) > 0) {
    foreach ($hoso_thanhpho as $item) {
        if ($item->thanhpho->name == '')
            continue;
        ?>
            $('#ThongTinNgheNghiepForm_noilamviecmongmuon_tinhthanh option[value="<?php echo $item->thanhpho->id; ?>"]').attr('disabled','disabled');
            $('#ThongTinNgheNghiepForm_noilamviecmongmuon_tinhthanh option[value="<?php echo $item->thanhpho->id; ?>"]').attr('selected','selected');
            $('#ThongTinNgheNghiepForm_noilamviecmongmuon_tinhthanh option[value="<?php echo $item->thanhpho->id; ?>"]').addClass('sel');
        <?php
    }
}
?>
        
                //check limit
                var nn = <?php echo count($hoso_nganhnghe) > 0 ? count($hoso_nganhnghe) + 1 : 0; ?>;
                var tp = <?php echo count($hoso_thanhpho) > 0 ? count($hoso_thanhpho) + 1 : 0; ?>;
                var qg = <?php echo count($hoso_quocgia) > 0 ? count($hoso_quocgia) + 1 : 0; ?>;
                /* nganh nghe*/
                $('#ThongTinNgheNghiepForm_nganhnghe').change(function(){
            
                    var t = $(this);
                    var op_value = t.val();
                    //check
                    if(op_value == '')
                        return false;
                    if(nn >= 4){
                        nn = 4;
                        alert('Chỉ được chọn tối đa 3 ngành nghề');
                        return false;
                    }
                    ++nn;
                    var op_text = $('#ThongTinNgheNghiepForm_nganhnghe option[value="'+ op_value +'"]').text();
        
                    $('<li>'+op_text+'<span class="del-sub-nn">Xóa</span><input type="hidden" name="ThongTinNgheNghiepForm[nganhnghe][]" value="'+ op_value +'" /></li>').fadeIn(500).appendTo('#sub-nganhgnhe');

                    $('#ThongTinNgheNghiepForm_nganhnghe option[value="'+ op_value +'"]').attr('disabled','disabled');
                    $('#ThongTinNgheNghiepForm_nganhnghe option[value="'+ op_value +'"]').attr('selected','selected');
                    $('#ThongTinNgheNghiepForm_nganhnghe option[value="'+ op_value +'"]').addClass('sel');
                    
                    //delete
                    $('.del-sub-nn').click(function(e){
                        --nn;
                        if(nn < 1)
                            nn = 1;
                
                        $(this).parent().fadeOut(500).remove();
                        $('#ThongTinNgheNghiepForm_nganhnghe option[value="'+ op_value +'"]').removeAttr('selected');
                        $('#ThongTinNgheNghiepForm_nganhnghe option[value="'+ op_value +'"]').removeAttr('disabled');
                        $('#ThongTinNgheNghiepForm_nganhnghe option[value="'+ op_value +'"]').removeClass('sel');
                        e.preventDefault();
                    });
                });
                $('.del-sub-nn').click(function(e){
                    op_value = $(this).parent().find('input').attr('value');
                    --nn;
                    if(nn < 1)
                        nn = 3;
                
                    $(this).parent().fadeOut(500).remove();
                    $('#ThongTinNgheNghiepForm_nganhnghe option[value="'+ op_value +'"]').removeAttr('selected');
                    $('#ThongTinNgheNghiepForm_nganhnghe option[value="'+ op_value +'"]').removeAttr('disabled');
                    $('#ThongTinNgheNghiepForm_nganhnghe option[value="'+ op_value +'"]').removeClass('sel');
                    e.preventDefault();
                });
                
                /* ngoai ngu*/
        var _stt = 2;
        var _nn_html = $('.nn-row').html() + '</p>';
        var _icon ;   
    
        $('.add-nn').click(function(e){
            if(_stt > 5)
                return false;
            _row = "<p class='nn-row stt-"+ _stt +" ' stt='"+ _stt +"'>";
            _icon = '<div class="btn-add-nn stt-'+ _stt +'" stt="'+ _stt +'"><i class="icon-minus-sign"></i><a href="#" class="del-nn">Xóa</a></span></div>';
            $(_row + _nn_html + _icon).fadeIn(500).appendTo('.sub-nn');
            _stt++;
        
            //delete ngoai ngu
            $('.del-nn').click(function(ev){
            
                var s = $(this).parent('.btn-add-nn').attr('stt')
                $('.stt-'+s).fadeOut(500).remove();
                _stt--;
                if(_stt < 2)
                    _stt = 2;
                ev.preventDefault();
            });
        });   
        //delete ngoai ngu
            $('.del-nn').click(function(ev){
                var s = $(this).parent('.btn-add-nn').attr('stt')
                $('.stt-'+s).fadeOut(500).remove();
                _stt--;
                if(_stt < 2)
                    _stt = 2;
                ev.preventDefault();
            });
        /*Hinh thuc*/
        $('#ThongTinNgheNghiepForm_hinhthuc').change(function(){
            
            var t = $(this);
            var op_value = t.val();
            //check
            if(op_value == '')
                return false;
            var op_text = $('#ThongTinNgheNghiepForm_hinhthuc option[value="'+ op_value +'"]').text();
        
            $('<li>'+op_text+'<span class="del-sub-ht">Xóa</span><input type="hidden" name="ThongTinNgheNghiepForm[hinhthuc][]" value="'+ op_value +'" /></li>').fadeIn(500).appendTo('#sub-hinhthuc');

            $('#ThongTinNgheNghiepForm_hinhthuc option[value="'+ op_value +'"]').attr('disabled','disabled');
            $('#ThongTinNgheNghiepForm_hinhthuc option[value="'+ op_value +'"]').attr('selected','selected');
            $('#ThongTinNgheNghiepForm_hinhthuc option[value="'+ op_value +'"]').addClass('sel');
            $('.del-sub-ht').click(function(e){
                $(this).parent().fadeOut(500).remove();
                $('#ThongTinNgheNghiepForm_hinhthuc option[value="'+ op_value +'"]').removeAttr('selected');
                $('#ThongTinNgheNghiepForm_hinhthuc option[value="'+ op_value +'"]').removeAttr('disabled');
                $('#ThongTinNgheNghiepForm_hinhthuc option[value="'+ op_value +'"]').removeClass('sel');
                e.preventDefault();
            });
        });
        //delete hinh thuc
            $('.del-sub-ht').click(function(e){
                op_value = $(this).parent().find('input').attr('value');
                $(this).parent().fadeOut(500).remove();
                $('#ThongTinNgheNghiepForm_hinhthuc option[value="'+ op_value +'"]').removeAttr('selected');
                $('#ThongTinNgheNghiepForm_hinhthuc option[value="'+ op_value +'"]').removeAttr('disabled');
                $('#ThongTinNgheNghiepForm_hinhthuc option[value="'+ op_value +'"]').removeClass('sel');
                e.preventDefault();
            });
            $('.del-sub-qg').click(function(e){
                op_value = $(this).parent().find('input').attr('value');
                --qg;
                if(qg < 1)
                    qg = 1;
                $(this).parent().fadeOut(500).remove();
                $('#ThongTinNgheNghiepForm_noilamviecmongmuon_quocgia option[value="'+ op_value +'"]').removeAttr('selected');
                $('#ThongTinNgheNghiepForm_noilamviecmongmuon_quocgia option[value="'+ op_value +'"]').removeAttr('disabled');
                $('#ThongTinNgheNghiepForm_noilamviecmongmuon_quocgia option[value="'+ op_value +'"]').removeClass('sel');
                e.preventDefault();
            });
            $('.del-sub-tt').click(function(e){
                op_value = $(this).parent().find('input').attr('value');
                --tp;
                if(tp < 1)
                    tp = 1;
                $(this).parent().fadeOut(500).remove();
                $('#ThongTinNgheNghiepForm_noilamviecmongmuon_tinhthanh option[value="'+ op_value +'"]').removeAttr('selected');
                $('#ThongTinNgheNghiepForm_noilamviecmongmuon_tinhthanh option[value="'+ op_value +'"]').removeAttr('disabled');
                $('#ThongTinNgheNghiepForm_noilamviecmongmuon_tinhthanh option[value="'+ op_value +'"]').removeClass('sel');
                e.preventDefault();
            });
        /* loai hinh*/
        $('#ThongTinNgheNghiepForm_loaihinh').change(function(){
            var t = $(this);
            var op_value = t.val();
            //check
            if(op_value == '')
                return false;
            var op_text = $('#ThongTinNgheNghiepForm_loaihinh option[value="'+ op_value +'"]').text();
        
            $('<li>'+op_text+'<span class="del-sub-lh">Xóa</span><input type="hidden" name="ThongTinNgheNghiepForm[loaihinh][]" value="'+ op_value +'" /></li>').fadeIn(500).appendTo('#sub-loaihinh');

            $('#ThongTinNgheNghiepForm_loaihinh option[value="'+ op_value +'"]').attr('disabled','disabled');
            $('#ThongTinNgheNghiepForm_loaihinh option[value="'+ op_value +'"]').attr('selected','selected');
            $('#ThongTinNgheNghiepForm_loaihinh option[value="'+ op_value +'"]').addClass('sel');
            $('.del-sub-lh').click(function(e){
                $(this).parent().fadeOut(500).remove();
                $('#ThongTinNgheNghiepForm_loaihinh option[value="'+ op_value +'"]').removeAttr('selected');
                $('#ThongTinNgheNghiepForm_loaihinh option[value="'+ op_value +'"]').removeAttr('disabled');
                $('#ThongTinNgheNghiepForm_loaihinh option[value="'+ op_value +'"]').removeClass('sel');
                e.preventDefault();
            });
        });
        $('.del-sub-lh').click(function(e){
                op_value = $(this).parent().find('input').attr('value');
                $(this).parent().fadeOut(500).remove();
                $('#ThongTinNgheNghiepForm_loaihinh option[value="'+ op_value +'"]').removeAttr('selected');
                $('#ThongTinNgheNghiepForm_loaihinh option[value="'+ op_value +'"]').removeAttr('disabled');
                $('#ThongTinNgheNghiepForm_loaihinh option[value="'+ op_value +'"]').removeClass('sel');
                e.preventDefault();
            });
        /* quoc gia */
        $('#ThongTinNgheNghiepForm_noilamviecmongmuon_quocgia').change(function(){
            var t = $(this);
            var op_value = t.val();
            //check
            if(op_value == '')
                return false;
            if(qg >= 4){
                alert('Chỉ được chọn tối đa 3 quốc gia');
                qg = 4;
                return false;
            }
            ++qg;
            var op_text = $('#ThongTinNgheNghiepForm_noilamviecmongmuon_quocgia option[value="'+ op_value +'"]').text();
        
            $('<li>'+op_text+'<span class="del-sub-qg">Xóa</span><input type="hidden" name="ThongTinNgheNghiepForm[noilamviecmongmuon][quocgia][]" value="'+ op_value +'" /></li>').fadeIn(500).appendTo('#sub-quocgia');

            $('#ThongTinNgheNghiepForm_noilamviecmongmuon_quocgia option[value="'+ op_value +'"]').attr('disabled','disabled');
            $('#ThongTinNgheNghiepForm_noilamviecmongmuon_quocgia option[value="'+ op_value +'"]').attr('selected','selected');
            $('#ThongTinNgheNghiepForm_noilamviecmongmuon_quocgia option[value="'+ op_value +'"]').addClass('sel');
            $('.del-sub-qg').click(function(e){
                --qg;
                if(qg < 1)
                    qg = 1;
                $(this).parent().fadeOut(500).remove();
                $('#ThongTinNgheNghiepForm_noilamviecmongmuon_quocgia option[value="'+ op_value +'"]').removeAttr('selected');
                $('#ThongTinNgheNghiepForm_noilamviecmongmuon_quocgia option[value="'+ op_value +'"]').removeAttr('disabled');
                $('#ThongTinNgheNghiepForm_noilamviecmongmuon_quocgia option[value="'+ op_value +'"]').removeClass('sel');
                e.preventDefault();
            });
        });
        
        /* tinh thanh */
        $('#ThongTinNgheNghiepForm_noilamviecmongmuon_tinhthanh').change(function(){
            
            var t = $(this);
            var op_value = t.val();
            //check
            if(op_value == '')
                return false;
            if(tp >= 4){
                tp = 4;
                alert('Chỉ được chọn tối đa 3 tỉnh thành');
            }else{
                ++tp;
                var op_text = $('#ThongTinNgheNghiepForm_noilamviecmongmuon_tinhthanh option[value="'+ op_value +'"]').text();

                $('<li>'+op_text+'<span class="del-sub-tt">Xóa</span><input type="hidden" name="ThongTinNgheNghiepForm[noilamviecmongmuon][tinhthanh][]" value="'+ op_value +'" /></li>').fadeIn(500).appendTo('#sub-tinhthanh');

                $('#ThongTinNgheNghiepForm_noilamviecmongmuon_tinhthanh option[value="'+ op_value +'"]').attr('disabled','disabled');
                $('#ThongTinNgheNghiepForm_noilamviecmongmuon_tinhthanh option[value="'+ op_value +'"]').attr('selected','selected');
                $('#ThongTinNgheNghiepForm_noilamviecmongmuon_tinhthanh option[value="'+ op_value +'"]').addClass('sel');
                $('.del-sub-tt').click(function(e){
                    --tp;
                    if(tp < 1)
                        tp = 1;
                    $(this).parent().fadeOut(500).remove();
                    $('#ThongTinNgheNghiepForm_noilamviecmongmuon_tinhthanh option[value="'+ op_value +'"]').removeAttr('selected');
                    $('#ThongTinNgheNghiepForm_noilamviecmongmuon_tinhthanh option[value="'+ op_value +'"]').removeAttr('disabled');
                    $('#ThongTinNgheNghiepForm_noilamviecmongmuon_tinhthanh option[value="'+ op_value +'"]').removeClass('sel');
                    e.preventDefault();
                });
            }
        });
        
});//end document
</script>